package com.spring.sunflower.userinfo;

import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.spring.sunflower.R;
import com.spring.sunflower.bean.LabelBean;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
 * Created by Kevin on 2021/6/28<br/>
 * <p>
 * Describe:<br/>
 */
public class HobbyAdapter extends BaseQuickAdapter<LabelBean.DatasBean, BaseViewHolder> {
    public HobbyAdapter(int layoutResId, @Nullable List<LabelBean.DatasBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, LabelBean.DatasBean datasBean) {
        TextView tv = baseViewHolder.getView(R.id.tvLabel);
        GradientDrawable background = (GradientDrawable) tv.getBackground();
        if (datasBean.isChecked()) {
            background.setColor(Color.parseColor("#" + datasBean.getColor()));
        } else {
            background.setColor(Color.parseColor("#CCCCCC"));
        }
        tv.setText(datasBean.getName());
    }
}
